home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / pcmagazi / 1992 / 12 / modechk.c < prev    next >
C/C++ Source or Header  |  1992-01-22  |  3KB  |  79 lines

  1. // modechk.c 
  2.  
  3. #include<windows.h>
  4.  
  5. int PASCAL WinMain(HANDLE, HANDLE, LPSTR, int);
  6. long FAR PASCAL WndProc(HWND, unsigned int, WORD, long);
  7.  
  8. char *szWinDebug = "WinDebug";
  9.  
  10. int PASCAL WinMain(HANDLE hInstance,HANDLE hPrevInstance, LPSTR lpCmdLine,
  11.     int nCmdShow)
  12.     {
  13.     HWND WndMain;       // window handle
  14.     MSG msg;
  15.    
  16.     if(!GetSystemMetrics(SM_DEBUG))     // if not DEBUG mode
  17.         return FALSE;                   // get outta Dodge
  18.  
  19.     if(!hPrevInstance)   /* If this is the first instance, register the class */
  20.         {
  21.         WNDCLASS wc;         /* Structure for registering window class */
  22.         wc.style         = NULL;
  23.         wc.lpfnWndProc   = WndProc;
  24.         wc.cbClsExtra    = 0;
  25.         wc.cbWndExtra    = 0;
  26.         wc.hInstance     = hInstance;
  27.         wc.hIcon = LoadIcon (hInstance, "ModeIcon");
  28.         wc.hbrBackground = NULL; 
  29.         wc.lpszClassName = szWinDebug;
  30.         wc.hCursor       = LoadCursor(NULL,IDC_ARROW);
  31.         wc.lpszMenuName  = NULL;
  32.         if(!RegisterClass(&wc))
  33.             return FALSE;
  34.         }
  35.     WndMain = CreateWindow(szWinDebug,szWinDebug,
  36.         WS_CAPTION | WS_SYSMENU | WS_ICONIC,
  37.         CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
  38.         NULL,NULL, hInstance, NULL);
  39.  
  40.     if(!WndMain)
  41.         return FALSE;
  42.  
  43.     ShowWindow(WndMain,SW_SHOWMINNOACTIVE);     // display as an icon
  44.     UpdateWindow(WndMain);                      
  45.  
  46.     while(GetMessage(&msg,NULL,NULL,NULL))      // std message loop
  47.         {
  48.         TranslateMessage(&msg);
  49.         DispatchMessage(&msg);
  50.         }
  51.     return msg.wParam;
  52.     }
  53.  
  54. long FAR PASCAL WndProc(HWND hWnd,unsigned int message,
  55.     WORD wParam,long lParam)
  56.     {
  57.     switch (message) 
  58.         {
  59.         case WM_CREATE:         // when window is created,
  60.             {                   // remove unneeded SysMenu items
  61.             HMENU hSysMenu = GetSystemMenu(hWnd,0);
  62.             RemoveMenu(hSysMenu, SC_RESTORE, MF_BYCOMMAND);
  63.             RemoveMenu(hSysMenu, SC_MINIMIZE, MF_BYCOMMAND);
  64.             RemoveMenu(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
  65.             RemoveMenu(hSysMenu, SC_SIZE, MF_BYCOMMAND);
  66.             }
  67.             break;
  68.         case WM_CLOSE:              
  69.             DestroyWindow(hWnd); 
  70.             break;
  71.         case WM_DESTROY:           
  72.             PostQuitMessage(0);
  73.             break;
  74.         default:
  75.             return DefWindowProc(hWnd,message,wParam,lParam);
  76.         }
  77.     return 0L;
  78.     }
  79.